﻿using UnityEngine;
using System.Collections;

public class MakeCloudSingletons : MonoBehaviour {

	public static MakeCloudSingletons Instance { get; private set; }

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	void Awake() {
		// First we check if there are any other instances conflicting
		if(Instance != null && Instance != this)
		{
			// If that is the case, we destroy other instances
			Destroy(gameObject);
		}
		
		// Here we save our singleton instance
		Instance = this;
		
		// Furthermore we make sure that we don't destroy between scenes (this is optional)
		DontDestroyOnLoad(gameObject);
		
		for (int z=0; z<this.transform.childCount; z++) {
			DontDestroyOnLoad(this.transform.GetChild(z).gameObject);
		}
	}
}